﻿using Abp.Application.Services;
using Abp.Domain.Repositories;
using Abp.Linq.Extensions;
using AbpVueDemo.MaterialsDemo.LingYongManager.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AbpVueDemo.MaterialsDemo.LingYongManager
{
    public class LingYService : AsyncCrudAppService<LingYonger,LingYInputDto, int, PageLingYDto, LingYCreateDto, LingYUpdateDto>, ILingYService
    {
        public LingYService(
      IRepository<LingYonger, int> repository) : base(repository)
        {

        }
        protected override IQueryable<LingYonger> CreateFilteredQuery(PageLingYDto input)
        {
            return base.CreateFilteredQuery(input)
                .WhereIf(!string.IsNullOrEmpty(input.lingypeo), c => c.lingypeo.Contains(input.lingypeo))
                .WhereIf(input.Lingytime!=null, c => c.Lingytime==(input.Lingytime))
                .WhereIf(!string.IsNullOrEmpty(input.shenpipeo), c => c.shenpipeo.Contains(input.shenpipeo));
        }
        [Microsoft.AspNetCore.Mvc.HttpPost]
        public async Task<bool> DeleteAll(List<int> ids)
        {
            foreach (var del in ids)
            {
                Repository.Delete(del);
            }
            return true;
        }
    }
}
